<!--可以通过http_server的服务启动 http://swoole.test:8811/ws_client.html-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>swoole-ws测试</h1>
    <script>
        var wsUrl = "ws://swoole.test:8812";
        var websocket = new WebSocket(wsUrl);
        // 实例化对象的onopen属性
        websocket.onopen = function (evt) {
            //发送数据
            websocket.send('hello-6666');
            console.log('conected-swoole-success');
        }
        // 实例化onmessage
        websocket.onmessage = function (evt) {
            console.log('ws-server-return-data:' + evt.data);
        }
        //onclose
        websocket.onclose = function (evt) {
            console.log("close");
        }
        //onerror
        websocket.onerror = function (evt) {
            console.log("error" + evt.data);
        }
    </script>
</body>
</html>